from django.db import models
from apps.common.base.models import BaseModel
from apps.interface.advert.models import Advert
from apps.interface.pageConfig.models import PageConfig
from apps.interface.component.models import Component

class Node(BaseModel):

    status = (
        (0, "关闭"),
        (1, "正常"),
    )

    key=models.CharField("标识", max_length=200, blank=True, null=True, default='')
    pageConfig=models.ForeignKey(PageConfig, related_name='node_PageConfig', verbose_name='所属界面配置', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    component=models.ForeignKey(Component, related_name='node_component', verbose_name='组件', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    status = models.IntegerField("状态", choices=status, default=1)
    isShow=models.BooleanField("是否显示节点", blank=True, default=True)
    isTemplate=models.BooleanField("是否为模板", blank=True, default=False)
    # adverts = models.ManyToManyField(Advert, related_name='node_adverts', blank=True, default=[], db_constraint=False)
    query = models.CharField("参数", max_length=200, blank=True, null=True, default='')

    config = models.TextField("配置", max_length=10000, null=True, blank=True, default='')

    # 组件样式
    background=models.CharField("背景色", max_length=200, blank=True, null=True, default='FFFFFF')
    width=models.IntegerField("宽", default=750)
    height=models.IntegerField("高", default=100)
    marginTop=models.IntegerField("上边距", default=0)
    marginBottom=models.IntegerField("下边距", default=0)
    marginLeft=models.IntegerField("左边距", default=0)
    marginRight=models.IntegerField("右边距", default=0)
    paddingTop=models.IntegerField("上内边距", default=0)
    paddingBottom=models.IntegerField("下内边距", default=0)
    paddingLeft=models.IntegerField("左内边距", default=0)
    paddingRight=models.IntegerField("右内边距", default=0)
    number = models.IntegerField("每行显示数量", default=2)
    direction = models.CharField("滚动方向", max_length=200, blank=True, default='row')
    speed = models.IntegerField("每秒滚动长度", default=80)
    duration = models.IntegerField("每页滚动速度", default=2000)

    # 图文区域样式1
    isShowForFlex1=models.BooleanField("是否显示布局区域1", blank=True, default=True)
    flex_directionForFlex1=models.CharField("布局区域排列方向1", max_length=200, blank=True, default='column')
    align_itemsForFlex1=models.CharField("布局区域对齐方式1", max_length=200, blank=True, default='flex-start')
    justify_contentForFlex1=models.CharField("布局区域纵向对齐方式1", max_length=200, blank=True, default='flex-start')
    backgroundForFlex1=models.CharField("布局区域背景色1", max_length=200, blank=True, null=True, default='#FFFFFF')
    widthForFlex1=models.IntegerField("布局区域宽1", default=750)
    heightForFlex1=models.IntegerField("布局区域高1", default=100)
    marginTopForFlex1=models.IntegerField("布局区域宽1", default=750)
    marginBottomForFlex1=models.IntegerField("布局区域上边距1", default=0)
    marginLeftForFlex1=models.IntegerField("布局区域下边距1", default=0)
    marginRightForFlex1=models.IntegerField("布局区域左边距1", default=0)
    paddingTopForFlex1=models.IntegerField("布局区域右边距1", default=0)
    paddingBottomForFlex1=models.IntegerField("布局区域上内边距1", default=0)
    paddingLeftForFlex1=models.IntegerField("布局区域下内边距1", default=0)
    paddingRightForFlex1=models.IntegerField("布局区域右内边距1", default=0)
    richtext=models.CharField("富文本", max_length=2000, blank=True, default='')

    # 图文区域样式2
    isShowForFlex2=models.BooleanField("是否显示布局区域2", blank=True, default=True)
    flex_directionForFlex2=models.CharField("布局区域排列方向2", max_length=200, blank=True, default='column')
    align_itemsForFlex2=models.CharField("布局区域对齐方式2", max_length=200, blank=True, default='flex-start')
    justify_contentForFlex2 = models.CharField("布局区域纵向对齐方式1", max_length=200, blank=True, default='flex-start')
    backgroundForFlex2=models.CharField("布局区域背景色2", max_length=200, blank=True, null=True, default='#FFFFFF')
    widthForFlex2=models.IntegerField("布局区域宽2", default=750)
    heightForFlex2=models.IntegerField("布局区域高2", default=100)
    marginTopForFlex2=models.IntegerField("布局区域宽2", default=750)
    marginBottomForFlex2=models.IntegerField("布局区域上边距2", default=0)
    marginLeftForFlex2=models.IntegerField("布局区域下边距2", default=0)
    marginRightForFlex2=models.IntegerField("布局区域左边距2", default=0)
    paddingTopForFlex2=models.IntegerField("布局区域右边距2", default=0)
    paddingBottomForFlex2=models.IntegerField("布局区域上内边距2", default=0)
    paddingLeftForFlex2=models.IntegerField("布局区域下内边距2", default=0)
    paddingRightForFlex2=models.IntegerField("布局区域右内边距2", default=0)

    # 图片样式1
    isShowForCover1=models.BooleanField("是否显示cover1", blank=True, default=True)
    widthForCover1=models.IntegerField("cover宽1", default=750)
    heightForCover1=models.IntegerField("cover高1", default=300)
    borderRadiusForCover1=models.IntegerField("图片圆角1",default=0)
    marginTopForCover1=models.IntegerField("上边距1", default=0)
    marginBottomForCover1=models.IntegerField("下边距1", default=0)
    marginLeftForCover1=models.IntegerField("左边距1", default=0)
    marginRightForCover1=models.IntegerField("右边距1", default=0)
    modeForCover1=models.CharField("图片的裁剪模式1", max_length=200, blank=True, default='aspectFill')

    # 图片样式2
    isShowForCover2=models.BooleanField("是否显示cover2", blank=True, default=True)
    widthForCover2=models.IntegerField("cover宽2", default=200)
    heightForCover2=models.IntegerField("cover高2", default=100)
    borderRadiusForCover2=models.IntegerField("图片圆角2",default=0)
    marginTopForCover2=models.IntegerField("上边距2", default=0)
    marginBottomForCover2=models.IntegerField("下边距2", default=0)
    marginLeftForCover2=models.IntegerField("左边距2", default=0)
    marginRightForCover2=models.IntegerField("右边距2", default=0)
    modeForCover2=models.CharField("图片的裁剪模式2", max_length=200, blank=True, default='aspectFill')

    # 文本样式1
    isShowForText1=models.BooleanField("是否显示text1", blank=True, default=True)
    titleForText1=models.CharField("标题文字1", max_length=200, blank=True, default='')
    marginTopForText1=models.IntegerField("上边距1", default=0)
    marginBottomForText1=models.IntegerField("下边距1", default=0)
    marginLeftForText1=models.IntegerField("左边距1", default=0)
    marginRightForText1=models.IntegerField("右边距1", default=0)
    colorForText1=models.CharField("颜色1", max_length=200, blank=True, default='#333333')
    fontsizeForText1=models.IntegerField("字体大小1", default=30)
    fontweightForText1=models.CharField("字体粗细1", max_length=200, blank=True, default='')
    deleteLineForText1=models.CharField("显示原价删除线1", max_length=200, blank=True, default='')  # line-through

    # 文本样式2
    isShowForText2=models.BooleanField("是否显示text2", blank=True, default=True)
    titleForText2=models.CharField("标题文字2", max_length=200, blank=True, default='')
    marginTopForText2=models.IntegerField("上边距2", default=0)
    marginBottomForText2=models.IntegerField("下边距2", default=0)
    marginLeftForText2=models.IntegerField("左边距2", default=0)
    marginRightForText2=models.IntegerField("右边距2", default=0)
    colorForText2=models.CharField("颜色2", max_length=200, blank=True, default='#333333')
    fontsizeForText2=models.IntegerField("字体大小2", default=30)
    fontweightForText2=models.CharField("字体粗细2", max_length=200, blank=True, default='')
    deleteLineForText2=models.CharField("显示原价删除线2", max_length=200, blank=True, default='')  # line-through

    # 文本样式3
    isShowForText3=models.BooleanField("是否显示text3", blank=True, default=True)
    titleForText3=models.CharField("标题文字3", max_length=200, blank=True, default='')
    marginTopForText3=models.IntegerField("上边距3", default=0)
    marginBottomForText3=models.IntegerField("下边距3", default=0)
    marginLeftForText3=models.IntegerField("左边距3", default=0)
    marginRightForText3=models.IntegerField("右边距3", default=0)
    colorForText3=models.CharField("颜色3", max_length=200, blank=True, default='#333333')
    fontsizeForText3=models.IntegerField("字体大小3", default=30)
    fontweightForText3=models.CharField("字体粗细3", max_length=200, blank=True, default='')
    deleteLineForText3=models.CharField("显示原价删除线3", max_length=200, blank=True, default='')  # line-through

    # 文本样式4
    isShowForText4=models.BooleanField("是否显示text4", blank=True, default=True)
    titleForText4=models.CharField("标题文字4", max_length=200, blank=True, default='')
    marginTopForText4=models.IntegerField("上边距4", default=0)
    marginBottomForText4=models.IntegerField("下边距4", default=0)
    marginLeftForText4=models.IntegerField("左边距4", default=0)
    marginRightForText4=models.IntegerField("右边距4", default=0)
    colorForText4=models.CharField("颜色4", max_length=200, blank=True, default='#333333')
    fontsizeForText4=models.IntegerField("字体大小4", default=30)
    fontweightForText4=models.CharField("字体粗细4", max_length=200, blank=True, default='')
    deleteLineForText4=models.CharField("显示原价删除线4", max_length=200, blank=True, default='')  # line-through

    # 按钮1
    isShowForBtn1=models.BooleanField("是否显示按钮1", blank=True, default=True)
    widthForBtn1=models.IntegerField("宽1", default=200)
    heightForBtn1=models.IntegerField("高1", default=88)
    titleForBtn1=models.CharField("按钮标题1", max_length=200, blank=True, default='')
    fontweightForBtn1=models.CharField("按钮标题粗细1", max_length=200, blank=True, default='bold')
    marginTopForBtn1=models.IntegerField("上边距1", default=0)
    marginBottomForBtn1=models.IntegerField("下边距1", default=0)
    marginLeftForBtn1=models.IntegerField("左边距1", default=0)
    marginRightForBtn1=models.IntegerField("右边距1", default=0)
    colorForBtn1=models.CharField("按钮标题颜色1", max_length=200, blank=True, default='#FFFFFF')
    backgroundColorForBtn1=models.CharField("按钮背景颜色1", max_length=200, blank=True, default='#FC5E53')
    borderColorForBtn1 = models.CharField("按钮边框颜色1", max_length=200, blank=True, default='#FC5E53')
    fontsizeForBtn1=models.IntegerField("按钮字体大小1", default=28)
    borderRadiusForBtn1=models.IntegerField("按钮圆角1", default=0)

    # 按钮2
    isShowForBtn2=models.BooleanField("是否显示按钮2", blank=True, default=True)
    widthForBtn2=models.IntegerField("宽2", default=200)
    heightForBtn2=models.IntegerField("高2", default=88)
    titleForBtn2=models.CharField("按钮标题2", max_length=200, blank=True, default='')
    fontweightForBtn2=models.CharField("按钮标题粗细2", max_length=200, blank=True, default='bold')
    marginTopForBtn2=models.IntegerField("上边距2", default=0)
    marginBottomForBtn2=models.IntegerField("下边距2", default=0)
    marginLeftForBtn2=models.IntegerField("左边距2", default=0)
    marginRightForBtn2=models.IntegerField("右边距2", default=0)
    colorForBtn2=models.CharField("按钮标题颜色2", max_length=200, blank=True, default='#FFFFFF')
    backgroundColorForBtn2=models.CharField("按钮背景颜色2", max_length=200, blank=True, default='#FC5E53')
    borderColorForBtn2 = models.CharField("按钮边框颜色2", max_length=200, blank=True, default='#FC5E53')
    fontsizeForBtn2=models.IntegerField("按钮字体大小2", default=28)
    borderRadiusForBtn2=models.IntegerField("按钮圆角2", default=0)

    options1=models.CharField("可选项1", max_length=1000, blank=True, null=True, default='')
    options2=models.CharField("可选项2", max_length=1000, blank=True, null=True, default='')


    class Meta:
        verbose_name = 'Node'
        verbose_name_plural = verbose_name


# 通知栏 options1：静态static， 动态dynamic
# 如果是动态dynamic，取options1值：{"table":"learn", "key": "name"}